// pages/account/bill-detail/bill-detail.js

const app = getApp()
const { wxPost, wxGet, commonShare, serviceBusy } = require('../../../utils/common.js')

Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const { id,from } = options
    var pages = getCurrentPages()
    var prevPage = pages[pages.length - 2] //上一个页面
    let item=null
    if (prevPage) {
      const { list,unPayList } = prevPage.data
      if(from && from==='unPay'){
        item= unPayList && unPayList.find(o=>o.id===id)
      }else{
        item= list && list.find(o=>o.id===id)
      }
    }
    if (!item) {
      wx.showToast({
        title: '找不到记录!',
        duration: 2000
      })
      wx.navigateBack({
        delta: 1
      })
      return 
    }
    this.setData({ item, currency: item.infoId.settlementCurrency})
  },

  onShareAppMessage: function () {
    return commonShare()
  }
})